package Store;

import java.util.Vector;

import Auxiliary.Sequence_CondReact;
import Auxiliary.Sequence_String;
import DataView.EventInfo;
import Visualization.EventVis;



public class Event extends Element 
{
	EventInfo info=null;

	public Event(){}
	
	public Event(String name, Vector<Parameter> vector, Sequence_CondReact cr) 
	{
		info= new EventInfo();
		info.setInfo(name, vector, cr);
		mkElement(info);
	}
	
	public void mkElement(EventInfo aElIN) 
	{
		super.mkElement(aElIN);
		info=aElIN;
	}
	
	public void setInfo(EventInfo ei) 
	{
		mkElement(ei);		
	}

	public EventInfo getInfo()
	{
		return info;
	}
	
	public EventVis vis() 
	{
		Sequence_String conds = new Sequence_String();
		Sequence_String reacts = new Sequence_String();
		for (CondReact cr : info.getCondReact().getAll())
		{
			conds.UNordered_add(cr.getCond().getDescription());
			reacts.UNordered_add(cr.getReact().getDescription());
		}
		return new EventVis(getDescription(), conds, reacts); 
	}
	
	public String getDescription()
	{
		String des=info.getName()+"( ";
		
		int max=0; if(info.getParameters()!=null) max=info.getParameters().size();
		for(int i=0; i<max; i++)
		{
			des+=info.getParameters().get(i).getDescription();
			if(i!=max-1) des+=", ";
		}
		
		des+=");";
		
		return des;
	}

	public String getNameDes() 
	{
		String des=info.getName()+"(";
		
		int max=0; if(info.getParameters()!=null) max=info.getParameters().size();
		for(int i=0; i<max; i++)
		{
			des+=info.getParameters().get(i).getName();
			if(i!=max-1) des+=", ";
		}
		
		des+=")";
		
		return des;
	}
	

	
}